package events;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import addons.GestioneErrori;
import data.FastDart;
import data.Player;
import data.SlowDart;

/**
 * Classe per gestire il keyboard(cambia dardo,usa abilita).
 * 
 * @author TeamVulcan
 * 
 */
public class PlayerAction implements KeyListener, ActionListener {
	private Player player;
	private KeyEvent key;
	private final static int STEP = 10;

	@Override
	public void keyPressed(KeyEvent e) {

		this.key = e;
		switch (key.getKeyCode()) {
		case 49: // char:1 slowdart
			player.setDart(new SlowDart());
			break;
		case 50: // char:2 fastdart
			player.setDart(new FastDart());
			break;
		case 51: // char:3 ability
			player.activeAbility();
			break;
		case 48: // char:3 ability
			// player.setDardo(new FastDart());
			GestioneErrori.getGestore().ReportWarning(5);
			break;
		case KeyEvent.VK_LEFT: // left arrow: move left
			player.moveLeft(STEP);
			break;
		case KeyEvent.VK_RIGHT: // right arrow: move right
			player.moveRight(STEP);
			break;
		case KeyEvent.VK_UP: // top arrow: move top
			player.moveTop(STEP);
			break;
		case KeyEvent.VK_DOWN:// down arrow: move down
			player.moveDown(STEP);
			break;
		default:
			break;
		}
	}

	public PlayerAction(Player player) {
		super();
		this.player = player;
	}

	@Override
	public void keyReleased(KeyEvent e) {
	}

	@Override
	public void keyTyped(KeyEvent e) {
	}

	@Override
	public void actionPerformed(ActionEvent e) {
	}

}
